package jp.sourceforge.akjrcp.ui;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;

public class ImageCanvas extends Canvas implements PaintListener{
private Image image;
private Color color=new Color(null,0,0,0);//black;
private int width;
private int height;
	public ImageCanvas(Composite arg0, int arg1) {
		super(arg0, arg1);
		// TODO Auto-generated constructor stub
		this.addPaintListener(this);
	}
	
	public Point computeSize(int hintWidth,int hintHeight,boolean changed){
	//	log.info(hintWidth+","+hintHeight+","+changed);
		return new Point(320,240);
	}


	public void paintControl(PaintEvent e) {
		if(image==null){
			e.gc.setBackground(color);
			e.gc.fillRectangle(this.getClientArea());
		}else{
			e.gc.drawImage(image, 0, 0);
		}
	}

	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}

}
